package com.example.testspringwebflux.bean;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.support.AbstractBeanDefinition;

import java.util.*;

/**
 * TestBeanDefinition
 *
 * @author xule
 * @since 2024/06/03
 */
public class TestBeanDefinition extends AbstractBeanDefinition {

    private String parentName;

    @Override
    public AbstractBeanDefinition cloneBeanDefinition() {
        return new TestBeanDefinition();
    }

    @Override
    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    @Override
    public String getParentName() {
        return this.parentName;
    }

    public static void main(String[] args) throws Exception {
//        AnnotationConfigApplicationContext context =
//                new AnnotationConfigApplicationContext();
//        TestBeanDefinition beanDefinition = new TestBeanDefinition();
//        beanDefinition.setBeanClass(Test.class);
//        ConstructorArgumentValues values = new ConstructorArgumentValues();
//        values.addIndexedArgumentValue(0, "name");
//        values.addIndexedArgumentValue(1, "value");
//        beanDefinition.setConstructorArgumentValues(values);
//        context.registerBeanDefinition("test", beanDefinition);
//        context.refresh();
//
//        System.out.println(context.getBean("test"));
//        System.out.println(JSON.toJSONString(""));
//        JSONObject dd = JSON.parseObject("{\"channelNo\":\"channelNo\",\"productId\":\"productId\",\"subject\":\"畅爽冰激凌5G套餐129元\",\"provinceCode\":\"11\",\"cityCode\":\"110\",\"renewalType\":\"01\",\"showUrl\":\"http://www.baidu.com\",\"checkUserPic\":\"1\",\"orderVersion\":\"02\",\"percent\":0,\"renewalEffectiveTime\":\"20240801\",\"userCommonFlag\":\"1\",\"tranType\":\"2370\",\"configPrincipal\":190000,\"salesNo\":\"salesNo\",\"acceptChannel\":\"POS\",\"goodsDetail\":\"TYPE:移网|MODEL:存费送机|SPEC:型号|IMEI:\",\"goodsInfo\":\"6000003|FTTR|中国联通|全屋光宽带（FTTR）1主1从999元（U享合约专用）|无|1$$$6000001|手机|OPPO|OPPOA2m5G（6G+128G）|0|1\",\"cbOrderNo\":\"cbOrderNo\"}");
//        System.out.println(JSON.toJSONString(dd));

        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, Object> map = new HashMap<>();
        map.put("channelNo", "2");
        map.put("productId", "1");
        map.put("provinceCode", "d");
        map.put("cbOrderNo", "cbOrderNo");
        map.put("cityCode", "cityCode");
        String json = JSON.toJSONString(map);
        System.out.println(json);
        System.out.println(JSON.toJSONString(map, SerializerFeature.MapSortField));
        //{"channelNo":2,"productId":1,"provinceCode":"d","cbOrderNo":"cbOrderNo","cityCode":"cityCode"}
        //{"channelNo":2,"productId":1,"provinceCode":"d","cityCode":"cityCode","cbOrderNo":"cbOrderNo"}
        for (String d : map.keySet()) {
            System.out.println(d);
        }
        System.out.println(JSON.parseObject(json).toJSONString());
    }
}
